﻿namespace Dissemination.MVC.Controllers
{
    #region Using statements

    using System.Web.Mvc;
    using Repositories;
    using Models;

    #endregion

    [HandleError]
    public class HomeController : ControllerBase
    {

        [Authorize]
        public ActionResult Index()
        {
            // CreateExcel();
            if (User.IsInRole("Administrator") || (User.IsInRole("Demostrator")))
            {
                var repository = new ProgramRepository();
                Program program = repository.GetDefaultProgram();
                return program == null ? this.RedirectToAction("Index", "Program") : this.RedirectToAction("Details", "Program", new { id = program.ProgramID });
            }

            // TODO: Change about view for another 
            return this.User.IsInRole("Reporter") ? this.RedirectToAction("Index", "ReporterManager") : this.RedirectToAction("Index", "Account");
        }

        public ActionResult About()
        {
            return View();
        }
    }
}
